<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateDeviceGroupSnsTable extends Migration
{
  /**
   * Run the migrations.
   *
   * @return void
   */
  public function up()
  {
    Schema::create('device_group_sns', function (Blueprint $table) {
      $table->integer('device_group_id')
        ->unsigned()
        ->nullable();
      $table->foreign('device_group_id')->references('id')
        ->on('device_groups')->onDelete('cascade');
      $table->integer('sns_id')->unsigned()->nullable();
      $table->foreign('sns_id')->references('id')
        ->on('sns')->onDelete('cascade');
    });
  }

  /**
   * Reverse the migrations.
   *
   * @return void
   */
  public function down()
  {
    Schema::dropIfExists('device_group_sns');
  }
}
